<meta charset="UTF-8">
<style>
	.activeLi {
		background-color: rgba(228, 225, 225, 0.59) !important;
	}
	
	.nav>li>a:hover,
	.nav>li>a:active,
	.nav>li>a:focus {
		color: none;
		background: none;
	}
	
	.btn-box-tool {
		font-size: 14px;
	}
	
	.btn {
		margin: 0px;
	}
</style>
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
	<section class="content-header">
		<h1 style="text-align:center">
        	物料管理
        </h1>

	</section>

	<!-- Main content -->
	<section class="content">
		<div class="row">
			<div class="col-md-3" style="padding-right: 0px;">
				<div class="box">
					<div class="box-header">
						<h3 class="box-title">全部类别</h3>
						<div class="box-tools pull-right">
							<button type="button" class="btn btn-primary" ng-click="showAllM()"><i class="fa fa-align-justify"></i>&nbsp;查看全部</button>
							<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newBigC"><i class="fa fa-plus"></i></button>
						</div>
					</div>
					<!-- /.box-header -->

					<div class="box-body" style="height: 400px;overflow: auto;">
						<ul class="nav nav-stacked">
							<li class="bigC" ng-click="searchMateriel($event,c.id)" ng-repeat='c in bigCategorys track by $index '>
								<a href="">{{c.name}}
									<button type="button" style="padding-top: 0px; color: #3c8dbc;" class="btn btn-box-tool pull-right" ng-click="newSonM(c.name,c.id,$event)" title="新增"><i class="fa fa-plus"></i></button>
									<button type="button" style="padding-top: 0px;" class="btn btn-box-tool pull-right edit" ng-click="editBigC(c.name,c.id,$event)" title="修改"><i class="fa fa-edit"></i></button>
									<button type="button" style="padding-top: 0px;" class="btn btn-box-tool pull-right del" ng-click="delBigC(c,$event)" title="删除"><i class="fa fa-remove"></i></button>
								</a>

							</li>
						</ul>
					</div>

					<!-- /.box-body -->
				</div>
			</div>
			<div class="col-md-9" style="padding-left: 0px;">
				<div class="box">
					<div class="box-header">
						<h3 class="box-title" style="visibility: hidden;">隐藏表头说明</h3>
						<div class="box-tools">
							<div class="input-group input-group-sm" style="width: 170px;">
								<input type="text" name="table_search" class="form-control pull-right" placeholder="物料名称" ng-model='searchMaterie'>

								<div class="input-group-btn">
									<button type="button" class="btn btn-default"><i class="fa fa-search"></i></button>
								</div>
							</div>
						</div>
					</div>
					<!-- /.box-header -->
					<div class="box-body table-responsive" style="height: 400px;overflow: auto;">

						<table class="table table-hover">
							<tbody>
								<tr>
									<th>物料名称</th>
									<th>制作车间</th>
									<th>所属分类</th>
									<th>操作</th>
								</tr>
								<tr ng-repeat = 'm in materiels track by $index' ng-show='m.category_id == selectBigCiD || selectBigCiD == undefined'>
									<td>{{m.name}}</td>
									<td>{{m.workshop_name}}</td>
									<td>{{m.category_name}}</td>
									<td>
										<a href="" class="btn btn-lg edit" style="padding:0px" title="修改" ng-click="editM(m)"><i class="fa fa-edit"></i></a>
										<a href="" class="btn btn-lg del" style="padding:0px" title="删除" ng-click="delM(m)"><i class="fa  fa-close"></i></a>
									</td>
								</tr>
							</tbody>
						</table>

					</div>
					<!-- /.box-body -->
				</div>
			</div>
		</div>
		<!-- /.row -->
	</section>
	<!-- /.content -->
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-20
	描述：新增类别模态框
-->
<div class="modal fade" id="newBigC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content form-horizontal">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">新增类别</h4>
			</div>
			<div class="modal-body box-body">
				<div class="form-group">
					<label class="col-sm-3 control-label">类别名称</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="类别名称" ng-required="true" ng-model="newBigC.name">
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-success btn-lg" ng-click="saveNewBigC()">保存</button>
			</div>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-20
	描述：编辑类别模态框
-->
<div class="modal fade" id="editBigC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content form-horizontal">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">编辑类别</h4>
			</div>
			<div class="modal-body box-body">
				<div class="form-group">
					<label class="col-sm-3 control-label">类别名称</label>
					<div class="col-sm-9">
						<input type="text" class="form-control" placeholder="类别名称" ng-required="true" ng-model="editC.name">
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-success btn-lg" ng-click="sureEditBigC()">保存</button>
			</div>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-20
	描述：新增物料模态框
-->
<div class="modal fade" id="newSonM" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document" style="width: 75%;">
		<div class="modal-content" >
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="cancleNewM()"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">新增物料：{{modalName}}</h4>
			</div>
			<form>
			<div class="modal-body box-body">
				<div class="row">
					<div class="col-md-6" style="padding-right: 0px;">
						<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
							<div class="box-header">
								<h3 class="box-title">基础信息</h3>
							</div>
							<div class="box-body ">
								<div class="form-group">
									<label class="col-sm-4 control-label">物料名称</label>
									<div class="col-sm-8">
										<input type="text" class="form-control" placeholder="物料名称" ng-required='true' ng-model="newMData.name" maxlength="15">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label">制作车间</label>
									<div class="col-sm-8">
										<select type="text" class="form-control" placeholder="制作车间" ng-required='true' ng-options ="w.id as w.name for w in workshop" ng-model="newMData.workshop_id">
											<option value="" selected hidden>											
										</select>
									</div>
								</div>	
								<div class="form-group">
									<label class="col-sm-4 control-label">工序</label>
									<div class="col-sm-8">
										<select type="text" class="form-control" placeholder="工序" ng-required='true'
											ng-options ="p.id as p.name for p in procedure" ng-model="newMData.procedure_id">
											<option value="" selected hidden>
										</select>
									</div>
								</div>								
								<div class="form-group">
									<label class="col-sm-4 control-label">物料备注</label>
									<div class="col-sm-8">
										<textarea style="resize:none" rows="4" class="form-control" placeholder="物料备注" ng-model="newMData.remarks"></textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label">厨师</label>
									<div class="col-sm-8">
										<select class="form-control" ng-options="c.id as c.name for c in chefs" ng-model="newMData.chef_id">
											<option value="" selected hidden>	
										</select>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-6" style="padding-left: 0px;">
						<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
							<div class="box-header">
								<h3 class="box-title">其他信息</h3>
							</div>
							<div class="box-body ">
								<div class="form-group">
									<label class="col-sm-4 control-label">标准成分</label>
									<div class="col-sm-8">
										<textarea data-toggle="modal" data-target="#selectSons" style="resize:none" ng-model="textareaData" rows="4" class="form-control" placeholder="点击选择标准成分" readonly="readonly" ng-required='true'></textarea>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label">加工时长</label>
									<div class="col-sm-8 has-feedback">
										<input type="text" class="form-control" placeholder="加工时长" ng-required='true' ng-model="newMData.work_time">
										<span class="form-control-feedback">分钟</span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label">单位</label>
									<div class="col-sm-8">
										<select class="form-control" ng-required='true' ng-model="newMData.unit_id" ng-options="u.id as u.name for u in units">
											<option value="">----请选择单位----</option>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-4 control-label">出净率</label>
									<div class="col-sm-8">
										<input type="text" class="form-control col-sm-9" placeholder="出净率" ng-required='true' style="width:50%;" ng-model="newMData.net_ratio">
										<label style="padding-top: 7px;">%</label>
									</div>
								</div>
								<!--<div class="form-group">
									<label class="col-sm-4 control-label">负责人</label>
									<div class="col-sm-8">
										<select type="text" class="form-control" placeholder="负责人" ng-required='true' ng-model="newMData.workshop_leader_id" ng-options = 'w.id as w.name for w in workshop_leader'>
											<option value="" selected="selected" hidden="" class=""></option>
										</select>
									</div>
								</div>-->
								
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal" ng-click="cancleNewM()">取消</button>
				<button type="submit" class="btn btn-success btn-lg" ng-click="saveNewMaterie()">保存</button>
			</div>
			</form>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-21
	描述：编辑物料模态框
-->
<div class="modal fade" id="editSonM" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document" style="width: 75%;">
		<div class="modal-content" >
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">编辑物料：{{editMData.category_name}}</h4>
			</div>
			<form>
				<div class="modal-body box-body">
					<div class="row">
						<div class="col-md-6" style="padding-right: 0px;">
							<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
								<div class="box-body ">
									<div class="form-group">
										<label class="col-sm-4 control-label">物料名称</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" placeholder="物料名称" ng-required='true' ng-model="editMData.name" maxlength="10">
										</div>
									</div>
									<div class="form-group hidden">
										<label class="col-sm-4 control-label">单位</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" placeholder="单位">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label">制作车间</label>
										<div class="col-sm-8">
											<select type="text" class="form-control" placeholder="制作车间" ng-required='true' ng-model="editMData.workshop_id" ng-options = 'wk.id as wk.name for wk in workshop'></select>
										</div>
									</div>								
									<div class="form-group">
										<label class="col-sm-4 control-label">工序</label>
										<div class="col-sm-8">
											<select type="text" class="form-control" placeholder="规格" ng-required='true' ng-model="editMData.procedure_id" ng-options = 'p.id as p.name for p in procedure'>
											</select>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label">物料备注</label>
										<div class="col-sm-8">
											<textarea style="resize:none" rows="4" class="form-control" ng-model="editMData.remarks" placeholder="物料备注"></textarea>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label">厨师</label>
										<div class="col-sm-8">
											<select class="form-control" ng-options="c.id as c.name for c in chefs" ng-model="editMData.chef_id">
												<option value="" selected hidden>
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="col-md-6" style="padding-left: 0px;">
							<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
								<div class="box-body ">
									<div class="form-group">
										<label class="col-sm-4 control-label">标准成分</label>
										<div class="col-sm-8">
											<textarea data-toggle="modal" data-target="#selectSons" style="resize:none" rows="4" class="form-control" placeholder="点击选择标准成分" readonly="readonly" ng-model="textareaData"></textarea>
										</div>
									</div>
									<div class="form-group hidden">
										<label class="col-sm-4 control-label">原料成本</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" placeholder="原料成本" >
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label">加工时长</label>
										<div class="col-sm-8 has-feedback">
											<input type="text" class="form-control" placeholder="加工时长" ng-required='true' ng-model="editMData.work_time">
											<span class="form-control-feedback">分钟</span>
										</div>
									</div>
									<div class="form-group">
									<label class="col-sm-4 control-label">单位</label>
									<div class="col-sm-8">
										<select class="form-control" ng-required='true' ng-model="editMData.unit_id" ng-options="u.id as u.name for u in units">
											<option value="">----请选择单位----</option>
										</select>
									</div>
								</div>
									<div class="form-group">
										<label class="col-sm-4 control-label">出净率</label>
										<div class="col-sm-8">
											<input type="text" class="form-control col-sm-9" style="width:50%;" placeholder="出净率" ng-required='true' ng-model="editMData.net_ratio">
											<label style="padding-top: 7px;">%</label>
										</div>
									</div>
									<!--<div class="form-group">
										<label class="col-sm-4 control-label">负责人</label>
										<div class="col-sm-8">
											<select type="text" class="form-control" placeholder="负责人" ng-required='true' ng-model="editMData.workshop_leader_id" ng-options = 'w.id as w.name for w in workshop_leader'></select>
										</div>
									</div>-->
									
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal" ng-click="cancleEditM()">取消</button>
				<button type="submit" class="btn btn-success btn-lg" ng-click="saveEditM()">保存</button>
			</div>
			</form>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-20
	描述：编辑中选择成分
-->
<div class="modal fade" id="selectSons" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
	<div class="modal-dialog" role="document">
		<div class="modal-content ">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">编辑标准成分</h4>
			</div>
			<div class="modal-body box-body" style="height: 500px"> <!--;overflow-y: auto;overflow-x: hidden;-->
				<div class="row">
					<div class="col-md-6" style="padding-right: 0px;max-height: 500px; overflow-y: auto;">
						<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
							<div class="box-header">
								<h3 class="box-title">标准成分</h3>
								<div class="box-tools">
									<div class="input-group input-group-sm" style="width: 170px;">
										<input type="text" name="table_search" class="form-control pull-right" placeholder="物料名称" ng-model="searchMaterie">
										<div class="input-group-btn">
											<button type="button" class="btn btn-default"><i class="fa fa-search"></i></button>
										</div>
									</div>
								</div>
							</div>
							<div class="box-body ">
								<table class="table table-condensed">
									<tbody>
										<tr>
											<th>物料名称</th>
											<th colspan="2">
												<select class="form-control" style="height: 24px; padding: 0px;"  ng-model="selectBigCName">
													<option>全部类别</option>
													<option ng-repeat="c in allAllCategorys track by $index" >{{c.name}}</option>
												</select>
											</th>
										</tr>
										<tr ng-repeat="m in sonsMateriels track by $index" ng-show="m.categoryName == selectBigCName && m.id != editMData.id || selectBigCName == '全部类别' && m.id != editMData.id">
											<td>{{m.name}}</td>
											<td>{{m.unit}}</td>
											<td style="color: #005983;cursor: pointer;" ng-click="addM(m)"><i class="fa fa-angle-double-right"></i></td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
					<div class="col-md-6" style="padding-left: 0px;">
						<div class="box form-horizontal" style="border-top: 0px; box-shadow: none">
							<div class="box-header">
								<h3 class="box-title">已选物料</h3>
							</div>
							<div class="box-body ">
								<table class="table table-condensed">
									<tbody>
										<tr>
											<th>物料名称</th>
											<th>数量</th>
											<th>操作</th>
										</tr>
										<tr ng-repeat="s in selectM track by $index">
											<td>{{s.material_name}}</td>
											<td><input type="number" ng-model="s.material_count" class="form-control" style="height: 72%;padding: 1px;text-align: center;" /></td>
											<td style="color: #e21455;cursor: pointer;" ng-click="removeM(s.material_id)"><i class="fa fa-remove"></i></td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" ng-click="cancleSelectSon()">取消</button>
				<button type="button" class="btn btn-success btn-lg" ng-click="MToTextarea()">保存</button>
			</div>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-21
	描述：删除分类
-->
<div class="modal fade" id="delBigC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
	<div class="modal-dialog" role="document">
		<div class="modal-content ">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">提示</h4>
			</div>
			<div class="modal-body box-body">
					<h3 style="text-align:center">确定要删除{{delBigCData.name}}吗？</h3>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-success btn-lg" ng-click="sureDelBigC()">确定</button>
			</div>
		</div>
	</div>
</div>
<!--
	作者：leeeeyx@hotmail.com
	时间：2017-06-21
	描述：删除物料
-->
<div class="modal fade" id="delM" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
	<div class="modal-dialog" role="document">
		<div class="modal-content ">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">提示</h4>
			</div>
			<div class="modal-body box-body">
					<h3 style="text-align:center">确定要删除{{delMData.name}}吗？</h3>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default pull-left btn-lg" data-dismiss="modal">取消</button>
				<button type="button" class="btn btn-success btn-lg" ng-click="sureDelM()">确定</button>
			</div>
		</div>
	</div>
</div>
